import { validatePhone } from '@/utils/validate'
/* 是否金额 2位小数点*/
export const isMoneyTwo = (rule, value, callback) => {
  const reg = /^(0|[1-9]\d*)(\.\d{1,2})?$/
  if (value == '' || value == undefined || value == null) {
    callback()
  } else {
    if (!reg.test(value)) {
      callback(new Error('请输入合法的金额数字，最多两位小数'))
    } else {
      callback()
    }
  }
}
/* 是否金额 8位小数点 非必定*/
export const isMoneyEightNot = (rule, value, callback) => {
  const reg = /^(0|[1-9]\d*)(\.\d{1,8})?$/
  if (value == '' || value == undefined || value == null) {
    callback()
  } else {
    if (!reg.test(value)) {
      callback(new Error('请输入合法的金额数字，最多八位小数'))
    } else {
      callback()
    }
  }
}
/* 是否金额 8位小数点 -必填*/
export const isMoneyEight = (rule, value, callback) => {
  const reg = /^(0|[1-9]\d*)(\.\d{1,8})?$/
  if (!reg.test(value)) {
    callback(new Error('请输入合法的金额数字，最多八位小数'))
  } else {
    callback()
  }
}
// 新建项目表单规则
export const formRules = {
  proName: [
    { required: true, message: '项目名称不能为空', trigger: ['blur', 'change'] }
  ],
  proType: [
    { required: true, message: '项目属性不能为空', trigger: ['blur', 'change'] }
  ],
  // proNum: [{ required: true, message: '项目编号不能为空', trigger: 'blur' }],
  customer: [
    { required: true, message: '客户名称不能为空', trigger: ['blur', 'change'] }
  ],
  proSchedule: [
    { required: true, message: '项目阶段不能为空', trigger: ['blur', 'change'] }
  ],
  busType: [
    { required: true, message: '业务属性不能为空', trigger: ['blur', 'change'] }
  ],
  companyId: [
    { required: true, message: '归属单位不能为空', trigger: ['blur', 'change'] }
  ],
  cusLinkId: [
    {
      required: true,
      message: '客户联系人不能为空',
      trigger: ['blur', 'change']
    }
  ],
  principalId: [
    {
      required: true,
      message: '项目负责人不能为空',
      trigger: ['blur', 'change']
    }
  ],
  phone: [
    {
      required: true,
      // validator: validatePhone,
      message: '联系电话不能为空',
      trigger: ['blur', 'change']
    }
  ],
  proSum: [
    {
      required: false,
      message: '',
      trigger: ['blur', 'change']
    },
    {
      validator: isMoneyEightNot
    }
  ],
  proRemark: [
    { required: true, message: '项目描述不能为空', trigger: ['blur', 'change'] }
  ],
  tenderer: [
    { required: true, message: '投标单位不能为空', trigger: ['blur', 'change'] }
  ],
  tenderType: [
    { required: true, message: '招标形式不能为空', trigger: ['blur', 'change'] }
  ],
  projectScale: [
    {
      required: true,
      message: '项目规模不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  bidOpeningTime: [
    { required: true, message: '开标时间不能为空', trigger: ['blur', 'change'] }
  ],
  /**投标项目财务情况 */
  proSumResouce: [
    {
      required: true,
      message: ' 项目资金来源不能为空',
      trigger: ['blur', 'change']
    }
  ],
  proPaymentDeadline: [
    {
      required: true,
      message: '项目付款期限不能为空',
      trigger: ['blur', 'change']
    }
  ],
  bidBond: [
    {
      required: true,
      message: '投标保证金不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  bidBondDeadline: [
    {
      required: true,
      message: '投标保证金期限不能为空',
      trigger: ['blur', 'change']
    }
  ],
  bidServiceFee: [
    {
      required: true,
      message: '中标服务费金额不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  bidOtherCost: [
    {
      required: true,
      message: '投标其他费用不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  totalEstCost: [
    {
      required: true,
      message: '投标项目预计成本总价不能为空',
      trigger: 'change'
    }
  ],
  tenderOffer: [
    {
      required: true,
      message: '项目拟投标报价不能为空',
      trigger: ['blur', 'change']
    }
  ],
  hpPrice: [
    {
      required: true,
      message: '其中：硬件产品采购价不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  hardwareOffer: [
    {
      required: true,
      message: '其中：硬件产品拟报价不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  softwareCost: [
    {
      required: true,
      message: '软件产品成本(含开发)不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  softwareOffer: [
    {
      required: true,
      message: '软件产品拟报价不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  impCost: [
    {
      required: true,
      message: '实施费用成本不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  qgAmount: [
    {
      required: true,
      message: '质保金的金额不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  pb: [
    {
      required: true,
      message: '履约保证金不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  qgDeadline: [
    {
      required: true,
      message: '质保金的期限不能为空',
      trigger: ['blur', 'change']
    }
  ],
  pbDeadline: [
    {
      required: true,
      message: '履约保证金期限不能为空',
      trigger: ['blur', 'change']
    }
  ],
  impOffer: [
    {
      required: true,
      message: '实施费用拟报价不能为空',
      trigger: ['blur', 'change']
    },
    { validator: isMoneyEight }
  ],
  gm: [{ required: true, message: '投标项目毛利不能为空', trigger: 'change' }],
  gpRate: [{ required: true, message: '毛利率不能为空', trigger: 'change' }],
  businessBelong: [
    { required: true, message: '业务归属不能为空', trigger: 'change' }
  ]
}

// // 投标项目预计成本总价=其中：硬件产品采购价+软件产品成本（含开发）+实施费用成本

// // 项目拟投标报价=其中：硬件产品拟报价+软件产品拟报价+实施费用拟报价

// // 投标项目毛利（万元）=项目拟投标报价-投标项目预计成本总价-中标服务费金额-投标其他费用（如标书等）

// // 毛利率=投标项目毛利/项目拟投标报价
